﻿using Microsoft.AspNetCore.SignalR;
using SpringBean.netty.model;

namespace SpringBean.netty.handler.impl;

public class PrivateServiceImpl : ChatHandlerService
{
    public Task execute(Chat chat, Dictionary<string, string> user, HubCallerContext context, IHubCallerClients clients)
    {
        if (user.ContainsKey(chat.target!))
        {
            string target = user[chat.target!];
            clients.Client(target).SendAsync("receive", chat);
            return Task.CompletedTask;
        }
        chat.message = "好友不在线";
        clients.Client(context.ConnectionId).SendAsync("receive", chat);
        return Task.CompletedTask;
    }
}